package mm.chenchen.common.utils;

import java.util.Map;

public class PageParam {
    //时间戳
    private Long t;
    private int page;
    private int limit;
    private String key;

    public Long getT() {
        return t;
    }

    public void setT(Long t) {
        this.t = t;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public static PageParam getInstance(Map map) {
        PageParam param = new PageParam();
        param.setKey(map.get("key") == null ? null : map.get("key").toString());
        param.setPage(Integer.parseInt(map.get("page") == null ? null : map.get("page").toString()));
        param.setLimit(Integer.parseInt(map.get("limit") == null ? null : map.get("limit").toString()));
        param.setT(Long.parseLong(map.get("t") == null ? null : map.get("t").toString()));
        return param;
    }

    @Override
    public String toString() {
        return "PageParam{" +
                "t=" + t +
                ", page=" + page +
                ", limit=" + limit +
                ", key='" + key + '\'' +
                '}';
    }
}
